<?

if ($DATA['component']['id']) {
	
	$_record = array('id_data' => D_MB_SETTINGS, 'id_parent' => $DATA['component']['id'], 'assoc' => '');

	$_lang_indep = array(
		'og_type' => 'website', 
    	'og_latitude' => '',
    	'og_longitude' => '',
    	'og_email' => '',
    	'og_phone_number' => '',
    	'og_fax_number' => '',
		'b_type' => '',
		'b_show_faces' => '',
		'b_width' => '',
		'b_verb' => '',
		'b_font' => '',
		'b_color' => '',
	);

	$_lang_dep	= array('og_title', 'og_site_name', 'og_description', 
		'og_street_address', 'og_locality', 'og_region', 'og_postal_code', 'og_country_name');	// which fields are stored in language variations



	switch (action(array('editor_save'))) {
	
		case 'editor_save':

			$temp = array();
			
			foreach($_lang_indep as $k => $v)
				if (($t = trim(postdata($k))) !== '')
					$temp[] = array_merge($_record, array('name' => $k, 'value' => $t));

			foreach($DATA['langs'] as $lang)
				foreach($_lang_dep as $k)
					if (isset($_POST[$k][$lang['text']]) && (($t = trim($_POST[$k][$lang['text']])) !== ''))
						$temp[] = array_merge($_record, array('name' => $k, 'value' => $t, 'assoc' => $lang['text']));	// language dependent data

			dataset('db_delete', tb('data'), "(id_data=".D_MB_SETTINGS.") AND (id_parent={$DATA[component][id]})");
			dataset('db_insert', tb('data'), $temp);

/*
			if ($_FILES['image'] && ($fn = parse_fname($_FILES['image']['filename'])) && !in_array(strtolower($fn['ext']), $DENIED_EXT) && ($im = takeImage('image', $s['w'], $s['h'], $s['path']))) {
				
				$temp[] = array_merge($_record, array('name' => 'image', 'value' => $im['filename']));
				
				if ($DATA['object']['image'] && ($DATA['object']['image']['fn'] != $im['fn'])) 
					unlink("$_SERVER[DOCUMENT_ROOT]{$DATA['object'][image][fn]}");
					
			} else 
				if ($DATA['object']['image']) {
					$fn = parse_fname($DATA['object']['image']['fn']);
					$temp[] = array_merge($_record, array('name' => 'image', 'value' => "$fn[name].$fn[ext]"));
				}
*/
			
			return true;	// end of component edition
	}
	

	$DATA['settings'] = array_merge( $_lang_indep, datafetch_array('meta', D_MB_SETTINGS, $DATA['component']['id']));
	
	foreach($DATA['langs'] as $lang)
		$DATA['settings']['data'][$lang['text']] = datafetch_array('meta', D_MB_SETTINGS, $DATA['component']['id'], $lang['text']);
		
	return false;

} else exit;
